//
//  LGNavigationController.swift
//  微博框架
//
//  Created by ming on 16/10/3.
//  Copyright © 2016年 ming. All rights reserved.
//

import UIKit

class LGNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
    
        
    }
    
    @objc  func back(){
        popViewController(animated: true)
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        //非栈顶控制器
        if viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            if let vc = viewController as? LGBasiViewController{
            if viewControllers.count == 1 {
        vc.navItem.leftBarButtonItem = UIBarButtonItem(title: navigationItem.title ?? "返回", target: self, action: #selector(back),isBack:true)
            }else{
                        //设置全站返回按钮
               
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: "返回", target: self, action: #selector(back),isBack:true)

            }


            
        }
        }
        //从写父类方法
        super.pushViewController(viewController, animated: animated)
        
        
    }
    
    
    
    
 
}





